package com.graduationproject.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.graduationproject.entity.Dish;
import com.graduationproject.entity.dto.DishUserDTO;
import com.graduationproject.entity.DishMake;
import com.graduationproject.entity.DishRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author shkstart
 * @create 2023-12-04-14:31
 */
@Mapper
public interface DishMapper extends BaseMapper<Dish> {
    /**
     * 根据id查找菜品
     * @param id
     * @return
     */
//    Dish findDishById(Integer id);

    /**
     * 查询所有菜品
     * @return
     */
//    List<Dish> findDishesAll();

    /**
     * 搜索功能实现
     * @param
     * @return
     */
//    List<Dish> search(String input);

//    List<Dish> searchHotDishes(Integer type);

    @Select("SELECT\n" +
            "\td.*,\n" +
            "\tdm.makes \n" +
            "FROM\n" +
            "\t`dish` AS d\n" +
            "\tJOIN dish_make AS dm ON d.id = dm.dish_id where d.del_flag = 0\n" +
            "\t")
    List<Dish> findByPage();

    String findTotals();

//    void deleteDish(int row);

//    List<Dish> findAllById(Integer id);

    void dishPut(Dish dish);

    void dishMakePut(DishMake dishMakes);

    void addDishAndMake(Dish dish);

    void addDishMake(DishMake dishMake);

//    void deleteDishMake(int row);


    void addDishRecord(DishRecord dishRecord);

    List<DishRecord> getDishRecord(String username);

    List<DishRecord> findByTime(String startTime, String endTime,String username);

    int[] findHeatByTime(String startTime, String endTime, String username);


    @Select("SELECT\n" +
            "\td.*,\n" +
            "\tdm.makes \n" +
            "FROM\n" +
            "\t`dish` AS d\n" +
            "\tJOIN dish_make AS dm ON d.id = dm.dish_id")
    List<Dish> selectDishAndMake();

    @Select("select * from carousel_chart limit 4")
    List<Dish> getCarouselChart();
}
